{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "0960e213-1b3e-4936-8e0d-ccaecb464d84",
   "metadata": {},
   "source": [
    "## **实践任务4.1** 使用列表实现队列"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "ced78aeb-1acc-4ef1-9bc6-4e72a515e07d",
   "metadata": {},
   "outputs": [],
   "source": [
    "queue = []"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "bc9496cc-b391-46c3-b31d-1a5bd90c5e9a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['张三']"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "queue.append('张三')\n",
    "queue"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "0beb5570-fecb-48e9-b97e-7fd6254bdd40",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['张三', '李四']"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "queue.append('李四')\n",
    "queue"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "6c55fa55-17dd-4195-83f5-896a8061b9aa",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "服务: 张三\n",
      "排队：['李四']\n"
     ]
    }
   ],
   "source": [
    "processed = queue.pop(0)     # 出队\n",
    "print(f'服务: {processed}')\n",
    "print(f'排队：{queue}')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "981501dd-523c-4e25-b60a-8c854dbfcdb9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "服务: 李四\n",
      "排队：[]\n"
     ]
    }
   ],
   "source": [
    "processed = queue.pop(0)     # 出队\n",
    "print(f'服务: {processed}')\n",
    "print(f'排队：{queue}')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "84819da8-787f-406d-b0b9-542ee23ecf4f",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
